<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <title>Title</title>
  </head>
  <body>
    <script>
      const value = {
        arr: [1, 2, 3, [4, 5, { name: "jack" }]],
        msg: "this is a book",
        stu: {
          name: "marry",
          hobbies: ["a", "b", ["c", { msg: "ok" }]],
        },
      };

      function deepClone(value) {
        if (!value || typeof value !== "object") {
          return value;
        }

        const res = Array.isArray(value) ? [] : {};

        for (let key in value) {
          if (value.hasOwnProperty(key)) {
            res[key] = deepClone(value[key]);
          }
        }

        return res;
      }

      console.log(deepClone(value));
    </script>
  </body>
</html>
